package apps.puzzles;

import java.util.Scanner;

/**
 * @author Rahul Jain
 */
public class ATM {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int withdrawAmt = scanner.nextInt();
        double balance = scanner.nextDouble();
        if (balance < 0 || balance > 2000) {
            System.out.println("Not proper value for Balance");
        } else if (withdrawAmt <= 0) {
            System.out.println("Incorrect withdrawal amount.");
        } else {
            balance = withdrawAmt(withdrawAmt, balance);
            System.out.println("Remaining balance:" + balance);
        }
    }

    public static double withdrawAmt(int withdrawAmt, double balance) {
        if (withdrawAmt > balance) {
            System.out.println("Not sufficient balance");
            return balance;
        } else if (withdrawAmt % 5 != 0) {
            System.out.println("Incorrect withdrawal amount - Not in multiple of $5");
            return balance;
        } else {
            double bankCharges = 0.5;
            balance -= (withdrawAmt + bankCharges);
            System.out.println("Successful transaction");
            return balance;
        }
    }
}
